#!/usr/bin/python
# -*- coding: utf-8 -*-


import oauth
from binder import bind_api
from parsers import ModelParser


class SinaAPI(object):
    """class for sina weibo API"""
    def __init__(self, consumer, access_token=None, \
                host='api.t.sina.com.cn'):
        """constructor for SinaAPI"""
        self.consumer = consumer
        self.access_token = access_token
        self.host = host
        self.parser = ModelParser()

    """oauth 1.0"""
    """/oauth/request_token 获取 request_token"""
    get_request_token = bind_api(
        url='/oauth/request_token',
        method='POST',
        require_auth=True,
        data_format='string',
        data_type='token',
        allowed_params=['oauth_callback']
    )

    """/oauth/access_token 获取access_token"""
    get_access_token = bind_api(
        url='/oauth/access_token',
        method='POST',
        require_auth=True,
        data_format='string',
        data_type='token',
        allowed_params=['oauth_verifier']
    )

    """Timeline 获取下行数据集接口"""
    """/statuses/public_timeline 获取最新公共微博信息"""
    public_timeline_statuses = bind_api(
        url='/statuses/public_timeline.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['count', 'base_app']
    )

    """/statuses/friends_timeline 获取用户好友微博"""
    friends_timeline_statuses = bind_api(
        url='/statuses/friends_timeline.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['since_id', 'max_id', 'count', 'page', \
                        'base_app', 'feature']
    )

    """/statuses/user_timeline 获取特定用户的微博"""
    user_timeline_statuses = bind_api(
        url='/statuses/user_timeline.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['user_id', 'screen_name', 'since_id', \
                       'max_id', 'count', 'page', 'base_app', 'feature']
    )
    
    """/statuses/mentions 获取提到我的微博"""
    mentions_statuses = bind_api(
        url='/statuses/mentions.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['since_id', 'max_id', 'count', 'page'] 
    )

    """/statuses/comments_timeline 获取我回复的和回复我的微博"""
    comments_timeline_statuses = bind_api(
        url='/statuses/comments_timeline.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['since_id', 'max_id', 'count', 'page'] 
    )

    """/statuses/comments_by_me 获取我回复的微博"""
    comments_by_me_statuses = bind_api(
        url='/statuses/comments_by_me.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['since_id', 'max_id', 'count', 'page'] 
    )

    """/statuses/comments_to_me 获取回复我的微博"""
    comments_to_me_statuses = bind_api(
        url='/statuses/comments_to_me.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['since_id', 'max_id', 'count', 'page'] 
    )

    """/statuses/comments 获取某条微博的回复列表"""
    comments_statuses = bind_api(
        url='/statuses/comments.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['id', 'count', 'page'] 
    )

    """/statuses/counts 获取微博的评论数和转发数"""
    counts_statuses = bind_api(
        url='/statuses/counts.json',
        method='GET',
        require_auth='True',
        data_format='json',
        data_list=True,
        data_type='count',
        allowed_params=['ids']
    )

    """/statuses/repost_timeline 获取原创信息最新转发列表"""
    repost_timeline_statuses = bind_api(
        url='/statuses/repost_timeline.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['id', 'since_id', 'max_id', 'count', 'page'] 
    )
    
    """/statuses/repost_by_me 获取用户转发的最新微博列表"""
    repost_by_me_statuses = bind_api(
        url='/statuses/repost_by_me.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='weibo',
        allowed_params=['id', 'since_id', 'max_id', 'count', 'page'] 
    )

    """/statuses/unread 获取用户未读消息"""
    unread_statuses = bind_api(
        url='/statuses/unread.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_type='unread',
        allowed_params=['with_new_status', 'since_id']
    )

    """/statuses/reset_count 清空未读信息"""
    reset_count_statuses = bind_api(
        url='/statuses/reset_count.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='basic',
        allowed_params=['type']
    )

    """/emotions 获取表情列表"""
    emotions = bind_api(
        url='/emotions.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_list=True,
        data_type='emotion',
        allowed_params=['type', 'type'] 
    )

    """Weibo  微博相关接口"""
    """/statuses/show 根据ID 获取微博内容"""
    show_statuses = bind_api(
        url='/statuses/show.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=[],
        rest_params=['id']
    )
        
        
    """/statuses/update 发送一条微博"""
    update_statuses = bind_api(
        url='/statuses/update.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=['status', 'in_reply_to_status_id', \
                       'lat', 'long', 'annotations']
    )

    """/statuses/upload 发送一条带图片微博"""
    upload_statuses = bind_api(
        url='/statuses/upload.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=['status', 'lat', 'long'],
        additional_params=['pic'],
        multipart_form=True
    )

    """/statuses/destroy 删除一条微博"""
    destroy_statuses = bind_api(
        url='/statuses/destroy.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=[],
        rest_params=['id'],
    )

    """/statuses/repost 转发一条微博"""
    repost_statuses = bind_api(
        url='/statuses/repost.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=['id', 'status', 'is_comment'],
    )
    
    """/statuses/comment 评论一条微博"""
    comment_statuses = bind_api(
        url='/statuses/comment.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=['id', 'comment', 'cid', 'without_mention', \
                       'comment_ori']
    )
        
    """/statuses/comment_destroy 删除一条微博评论"""
    comment_destroy_statuses = bind_api(
        url='/statuses/comment_destroy.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=[],
        rest_params=['id'],
    )

    """/statuses/comment/destroy_batch 批量删除微博评论"""
    comment_destroy_batch_statuses = bind_api(
        url='/statuses/comment/destroy_batch.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        data_list=True,
        allowed_params=['ids']
    )

    """/statuses/reply 回复一条微博评论"""
    reply_statuses = bind_api(
        url='/statuses/reply.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='weibo',
        allowed_params=['cid', 'comment', 'id', 'without_mention']
    )

    """User 用户接口"""
    """/users/show 按用户id返回用户资料"""
    show_users = bind_api(
        url='/users/show.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='user',
        allowed_params=['user_id', 'screen_name']
    )

    """/statuses/friends 获取用户关注列表"""
    friends_statuses = bind_api(
        url='/statuses/friends.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_type='user',
        data_list=True,
        allowed_params=['user_id', 'screen_name', 'cursor', \
                       'count']
    )

    """/statuses/followers 获取用户粉丝列表"""
    followers_statuses = bind_api(
        url='/statuses/followers.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_type='user',
        data_list=True,
        allowed_params=['user_id', 'screen_name', 'cursor', \
                       'count']
    )

    """/users/hot 获取系统推荐用户列表"""
    hot_users = bind_api(
        url='/users/hot.json',
        method='GET',
        require_auth=True,
        data_format='json',
        data_type='user',
        data_list=True,
        allowed_params=['category']
    )

    """/user/friends/update_remark 修改好友的备注信息"""
    update_remark_friends_user = bind_api(
        url='/user/friends/update_remark.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='user',
        allowed_params=['user_id', 'remark']
    )

    """/users/suggestions 返回当前用户感兴趣的用户"""
    suggestions_users = bind_api(
        url='/users/suggestions.json',
        method='POST',
        require_auth=True,
        data_format='json',
        data_type='user',
        data_list=True,
        allowed_params=['with_reason']
    )

if __name__ == "__main__":
    pass
